package com.qdlc.p2p.dal.model;

import org.springframework.beans.BeanUtils;

import com.qdlc.p2p.common.exception.UserException;
import com.qdlc.p2p.common.util.MessageUtil;
import com.qdlc.p2p.common.util.ValidateUtil;
import com.qdlc.p2p.dal.dto.ExperienceBorrow;

/**
 * 体验标model
 * @author xxx
 * @version 2.0
 * @date 2015年4月23日 上午10:56:45
 */
public class ExperienceBorrowModel extends ExperienceBorrow {
	
	/** 当前页码 */
	private int page = 1;

	/** 每页数据条数 */
	private int rows = 5;

	private String borrowName;
	
	/**
	 * 条件查询
	 */
	private String searchName;
	
	public static ExperienceBorrowModel instance(ExperienceBorrow experienceBorrow) {
		ExperienceBorrowModel experienceBorrowModel = new ExperienceBorrowModel();
		BeanUtils.copyProperties(experienceBorrow, experienceBorrowModel);
		return experienceBorrowModel;
	}

	public ExperienceBorrow prototype() {
		ExperienceBorrow experienceBorrow = new ExperienceBorrow();
		BeanUtils.copyProperties(this, experienceBorrow);
		return experienceBorrow;
	}
	
	/**
	 * 检查提交的数据格式
	 * 
	 * @return
	 */
	public int validModelData() {
		if (!ValidateUtil.isAmount(getMostExperience())) {
			throw new UserException(MessageUtil.getMessage("MF102007004"), 1);
		}
		if (!ValidateUtil.isAmount(getMostExperienceSingle())) {
			throw new UserException(MessageUtil.getMessage("MF102007004"), 1);
		}
		return -1;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	public String getBorrowName() {
		return borrowName;
	}

	public void setBorrowName(String borrowName) {
		this.borrowName = borrowName;
	}

	public String getSearchName() {
		return searchName;
	}

	public void setSearchName(String searchName) {
		this.searchName = searchName;
	}


}
